package com.czk.practice.client;

import com.czk.practice.domain.Message1;
import com.czk.practice.domain.Message2;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/8/19 15:27
 */
public class MyClientHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        //
        System.out.println("接收到消息了，类型是" + msg.getClass());
        if (msg instanceof Message1) {
            Message1 message1 = (Message1) msg;
            System.out.println(new String(message1.getContent()));
        } else {
            Message2 message2 = (Message2) msg;
            System.out.println(new String(message2.getContent()));
        }
    }
}
